<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - id:000977,sync:fuzzer2,src:001052.lcov_info_final - src/scantoken.cpp</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../index.html">top level</a> - <a href="index.html">src</a> - scantoken.cpp<span style="font-size: 80%;"> (source / <a href="scantoken.cpp.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">id:000977,sync:fuzzer2,src:001052.lcov_info_final</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">247</td>
            <td class="headerCovTableEntry">247</td>
            <td class="headerCovTableEntryHi">100.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2016-03-13 10:42:47</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">16</td>
            <td class="headerCovTableEntry">16</td>
            <td class="headerCovTableEntryHi">100.0 %</td>
          </tr>
          <tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : #include &lt;sstream&gt;</a>
<span class="lineNum">       2 </span>            : 
<span class="lineNum">       3 </span>            : #include &quot;exp.h&quot;
<span class="lineNum">       4 </span>            : #include &quot;regex_yaml.h&quot;
<span class="lineNum">       5 </span>            : #include &quot;regeximpl.h&quot;
<span class="lineNum">       6 </span>            : #include &quot;scanner.h&quot;
<span class="lineNum">       7 </span>            : #include &quot;scanscalar.h&quot;
<span class="lineNum">       8 </span>            : #include &quot;scantag.h&quot;  // IWYU pragma: keep
<span class="lineNum">       9 </span>            : #include &quot;tag.h&quot;      // IWYU pragma: keep
<span class="lineNum">      10 </span>            : #include &quot;token.h&quot;
<span class="lineNum">      11 </span>            : #include &quot;yaml-cpp/exceptions.h&quot;  // IWYU pragma: keep
<span class="lineNum">      12 </span>            : #include &quot;yaml-cpp/mark.h&quot;
<span class="lineNum">      13 </span>            : 
<span class="lineNum">      14 </span>            : namespace YAML {
<span class="lineNum">      15 </span>            : ///////////////////////////////////////////////////////////////////////
<span class="lineNum">      16 </span>            : // Specialization for scanning specific tokens
<span class="lineNum">      17 </span>            : 
<a name="18"><span class="lineNum">      18 </span>            : // Directive</a>
<span class="lineNum">      19 </span>            : // . Note: no semantic checking is done here (that's for the parser to do)
<span class="lineNum">      20 </span><span class="lineCov">       3161 : void Scanner::ScanDirective() {</span>
<span class="lineNum">      21 </span><span class="lineCov">       6322 :   std::string name;</span>
<span class="lineNum">      22 </span><span class="lineCov">       6322 :   std::vector&lt;std::string&gt; params;</span>
<span class="lineNum">      23 </span>            : 
<span class="lineNum">      24 </span>            :   // pop indents and simple keys
<span class="lineNum">      25 </span><span class="lineCov">       3161 :   PopAllIndents();</span>
<span class="lineNum">      26 </span><span class="lineCov">       3161 :   PopAllSimpleKeys();</span>
<span class="lineNum">      27 </span>            : 
<span class="lineNum">      28 </span><span class="lineCov">       3161 :   m_simpleKeyAllowed = false;</span>
<span class="lineNum">      29 </span><span class="lineCov">       3161 :   m_canBeJSONFlow = false;</span>
<span class="lineNum">      30 </span>            : 
<span class="lineNum">      31 </span>            :   // store pos and eat indicator
<span class="lineNum">      32 </span><span class="lineCov">       6322 :   Token token(Token::DIRECTIVE, INPUT.mark());</span>
<span class="lineNum">      33 </span><span class="lineCov">       3161 :   INPUT.eat(1);</span>
<span class="lineNum">      34 </span>            : 
<span class="lineNum">      35 </span>            :   // read name
<span class="lineNum">      36 </span><span class="lineCov">     900615 :   while (INPUT &amp;&amp; !Exp::BlankOrBreak().Matches(INPUT))</span>
<span class="lineNum">      37 </span><span class="lineCov">     448727 :     token.value += INPUT.get();</span>
<span class="lineNum">      38 </span>            : 
<span class="lineNum">      39 </span>            :   // read parameters
<span class="lineNum">      40 </span><span class="lineCov">      14408 :   while (1) {</span>
<span class="lineNum">      41 </span>            :     // first get rid of whitespace
<span class="lineNum">      42 </span><span class="lineCov">      47897 :     while (Exp::Blank().Matches(INPUT))</span>
<span class="lineNum">      43 </span><span class="lineCov">      15164 :       INPUT.eat(1);</span>
<span class="lineNum">      44 </span>            : 
<span class="lineNum">      45 </span>            :     // break on newline or comment
<span class="lineNum">      46 </span><span class="lineCov">      17569 :     if (!INPUT || Exp::Break().Matches(INPUT) || Exp::Comment().Matches(INPUT))</span>
<span class="lineNum">      47 </span><span class="lineCov">       3161 :       break;</span>
<span class="lineNum">      48 </span>            : 
<span class="lineNum">      49 </span>            :     // now read parameter
<span class="lineNum">      50 </span><span class="lineCov">      28816 :     std::string param;</span>
<span class="lineNum">      51 </span><span class="lineCov">    1243780 :     while (INPUT &amp;&amp; !Exp::BlankOrBreak().Matches(INPUT))</span>
<span class="lineNum">      52 </span><span class="lineCov">     614686 :       param += INPUT.get();</span>
<span class="lineNum">      53 </span>            : 
<span class="lineNum">      54 </span><span class="lineCov">      14408 :     token.params.push_back(param);</span>
<span class="lineNum">      55 </span>            :   }
<span class="lineNum">      56 </span>            : 
<span class="lineNum">      57 </span><span class="lineCov">       3161 :   m_tokens.push(token);</span>
<span class="lineNum">      58 </span><span class="lineCov">       3161 : }</span>
<a name="59"><span class="lineNum">      59 </span>            : </a>
<span class="lineNum">      60 </span>            : // DocStart
<span class="lineNum">      61 </span><span class="lineCov">        649 : void Scanner::ScanDocStart() {</span>
<span class="lineNum">      62 </span><span class="lineCov">        649 :   PopAllIndents();</span>
<span class="lineNum">      63 </span><span class="lineCov">        649 :   PopAllSimpleKeys();</span>
<span class="lineNum">      64 </span><span class="lineCov">        649 :   m_simpleKeyAllowed = false;</span>
<span class="lineNum">      65 </span><span class="lineCov">        649 :   m_canBeJSONFlow = false;</span>
<span class="lineNum">      66 </span>            : 
<span class="lineNum">      67 </span>            :   // eat
<span class="lineNum">      68 </span><span class="lineCov">        649 :   Mark mark = INPUT.mark();</span>
<span class="lineNum">      69 </span><span class="lineCov">        649 :   INPUT.eat(3);</span>
<span class="lineNum">      70 </span><span class="lineCov">        649 :   m_tokens.push(Token(Token::DOC_START, mark));</span>
<span class="lineNum">      71 </span><span class="lineCov">        649 : }</span>
<a name="72"><span class="lineNum">      72 </span>            : </a>
<span class="lineNum">      73 </span>            : // DocEnd
<span class="lineNum">      74 </span><span class="lineCov">        745 : void Scanner::ScanDocEnd() {</span>
<span class="lineNum">      75 </span><span class="lineCov">        745 :   PopAllIndents();</span>
<span class="lineNum">      76 </span><span class="lineCov">        745 :   PopAllSimpleKeys();</span>
<span class="lineNum">      77 </span><span class="lineCov">        745 :   m_simpleKeyAllowed = false;</span>
<span class="lineNum">      78 </span><span class="lineCov">        745 :   m_canBeJSONFlow = false;</span>
<span class="lineNum">      79 </span>            : 
<span class="lineNum">      80 </span>            :   // eat
<span class="lineNum">      81 </span><span class="lineCov">        745 :   Mark mark = INPUT.mark();</span>
<span class="lineNum">      82 </span><span class="lineCov">        745 :   INPUT.eat(3);</span>
<span class="lineNum">      83 </span><span class="lineCov">        745 :   m_tokens.push(Token(Token::DOC_END, mark));</span>
<span class="lineNum">      84 </span><span class="lineCov">        745 : }</span>
<a name="85"><span class="lineNum">      85 </span>            : </a>
<span class="lineNum">      86 </span>            : // FlowStart
<span class="lineNum">      87 </span><span class="lineCov">      58587 : void Scanner::ScanFlowStart() {</span>
<span class="lineNum">      88 </span>            :   // flows can be simple keys
<span class="lineNum">      89 </span><span class="lineCov">      58587 :   InsertPotentialSimpleKey();</span>
<span class="lineNum">      90 </span><span class="lineCov">      58587 :   m_simpleKeyAllowed = true;</span>
<span class="lineNum">      91 </span><span class="lineCov">      58587 :   m_canBeJSONFlow = false;</span>
<span class="lineNum">      92 </span>            : 
<span class="lineNum">      93 </span>            :   // eat
<span class="lineNum">      94 </span><span class="lineCov">      58587 :   Mark mark = INPUT.mark();</span>
<span class="lineNum">      95 </span><span class="lineCov">      58587 :   char ch = INPUT.get();</span>
<span class="lineNum">      96 </span><span class="lineCov">      58587 :   FLOW_MARKER flowType = (ch == Keys::FlowSeqStart ? FLOW_SEQ : FLOW_MAP);</span>
<span class="lineNum">      97 </span><span class="lineCov">      58587 :   m_flows.push(flowType);</span>
<span class="lineNum">      98 </span>            :   Token::TYPE type =
<span class="lineNum">      99 </span><span class="lineCov">      58587 :       (flowType == FLOW_SEQ ? Token::FLOW_SEQ_START : Token::FLOW_MAP_START);</span>
<span class="lineNum">     100 </span><span class="lineCov">      58587 :   m_tokens.push(Token(type, mark));</span>
<span class="lineNum">     101 </span><span class="lineCov">      58587 : }</span>
<a name="102"><span class="lineNum">     102 </span>            : </a>
<span class="lineNum">     103 </span>            : // FlowEnd
<span class="lineNum">     104 </span><span class="lineCov">       8258 : void Scanner::ScanFlowEnd() {</span>
<span class="lineNum">     105 </span><span class="lineCov">       8258 :   if (InBlockContext())</span>
<span class="lineNum">     106 </span><span class="lineCov">         16 :     throw ParserException(INPUT.mark(), ErrorMsg::FLOW_END);</span>
<span class="lineNum">     107 </span>            : 
<span class="lineNum">     108 </span>            :   // we might have a solo entry in the flow context
<span class="lineNum">     109 </span><span class="lineCov">       8242 :   if (InFlowContext()) {</span>
<span class="lineNum">     110 </span><span class="lineCov">       8242 :     if (m_flows.top() == FLOW_MAP &amp;&amp; VerifySimpleKey())</span>
<span class="lineNum">     111 </span><span class="lineCov">       2090 :       m_tokens.push(Token(Token::VALUE, INPUT.mark()));</span>
<span class="lineNum">     112 </span><span class="lineCov">       6152 :     else if (m_flows.top() == FLOW_SEQ)</span>
<span class="lineNum">     113 </span><span class="lineCov">       4594 :       InvalidateSimpleKey();</span>
<span class="lineNum">     114 </span>            :   }
<span class="lineNum">     115 </span>            : 
<span class="lineNum">     116 </span><span class="lineCov">       8242 :   m_simpleKeyAllowed = false;</span>
<span class="lineNum">     117 </span><span class="lineCov">       8242 :   m_canBeJSONFlow = true;</span>
<span class="lineNum">     118 </span>            : 
<span class="lineNum">     119 </span>            :   // eat
<span class="lineNum">     120 </span><span class="lineCov">       8242 :   Mark mark = INPUT.mark();</span>
<span class="lineNum">     121 </span><span class="lineCov">       8242 :   char ch = INPUT.get();</span>
<span class="lineNum">     122 </span>            : 
<span class="lineNum">     123 </span>            :   // check that it matches the start
<span class="lineNum">     124 </span><span class="lineCov">       8242 :   FLOW_MARKER flowType = (ch == Keys::FlowSeqEnd ? FLOW_SEQ : FLOW_MAP);</span>
<span class="lineNum">     125 </span><span class="lineCov">       8242 :   if (m_flows.top() != flowType)</span>
<span class="lineNum">     126 </span><span class="lineCov">         37 :     throw ParserException(mark, ErrorMsg::FLOW_END);</span>
<span class="lineNum">     127 </span><span class="lineCov">       8205 :   m_flows.pop();</span>
<span class="lineNum">     128 </span>            : 
<span class="lineNum">     129 </span><span class="lineCov">       8205 :   Token::TYPE type = (flowType ? Token::FLOW_SEQ_END : Token::FLOW_MAP_END);</span>
<span class="lineNum">     130 </span><span class="lineCov">       8205 :   m_tokens.push(Token(type, mark));</span>
<span class="lineNum">     131 </span><span class="lineCov">       8205 : }</span>
<a name="132"><span class="lineNum">     132 </span>            : </a>
<span class="lineNum">     133 </span>            : // FlowEntry
<span class="lineNum">     134 </span><span class="lineCov">      33951 : void Scanner::ScanFlowEntry() {</span>
<span class="lineNum">     135 </span>            :   // we might have a solo entry in the flow context
<span class="lineNum">     136 </span><span class="lineCov">      33951 :   if (InFlowContext()) {</span>
<span class="lineNum">     137 </span><span class="lineCov">      33322 :     if (m_flows.top() == FLOW_MAP &amp;&amp; VerifySimpleKey())</span>
<span class="lineNum">     138 </span><span class="lineCov">       5984 :       m_tokens.push(Token(Token::VALUE, INPUT.mark()));</span>
<span class="lineNum">     139 </span><span class="lineCov">      27338 :     else if (m_flows.top() == FLOW_SEQ)</span>
<span class="lineNum">     140 </span><span class="lineCov">      10133 :       InvalidateSimpleKey();</span>
<span class="lineNum">     141 </span>            :   }
<span class="lineNum">     142 </span>            : 
<span class="lineNum">     143 </span><span class="lineCov">      33951 :   m_simpleKeyAllowed = true;</span>
<span class="lineNum">     144 </span><span class="lineCov">      33951 :   m_canBeJSONFlow = false;</span>
<span class="lineNum">     145 </span>            : 
<span class="lineNum">     146 </span>            :   // eat
<span class="lineNum">     147 </span><span class="lineCov">      33951 :   Mark mark = INPUT.mark();</span>
<span class="lineNum">     148 </span><span class="lineCov">      33951 :   INPUT.eat(1);</span>
<span class="lineNum">     149 </span><span class="lineCov">      33951 :   m_tokens.push(Token(Token::FLOW_ENTRY, mark));</span>
<span class="lineNum">     150 </span><span class="lineCov">      33951 : }</span>
<a name="151"><span class="lineNum">     151 </span>            : </a>
<span class="lineNum">     152 </span>            : // BlockEntry
<span class="lineNum">     153 </span><span class="lineCov">      22472 : void Scanner::ScanBlockEntry() {</span>
<span class="lineNum">     154 </span>            :   // we better be in the block context!
<span class="lineNum">     155 </span><span class="lineCov">      22472 :   if (InFlowContext())</span>
<span class="lineNum">     156 </span><span class="lineCov">         13 :     throw ParserException(INPUT.mark(), ErrorMsg::BLOCK_ENTRY);</span>
<span class="lineNum">     157 </span>            : 
<span class="lineNum">     158 </span>            :   // can we put it here?
<span class="lineNum">     159 </span><span class="lineCov">      22459 :   if (!m_simpleKeyAllowed)</span>
<span class="lineNum">     160 </span><span class="lineCov">          4 :     throw ParserException(INPUT.mark(), ErrorMsg::BLOCK_ENTRY);</span>
<span class="lineNum">     161 </span>            : 
<span class="lineNum">     162 </span><span class="lineCov">      22455 :   PushIndentTo(INPUT.column(), IndentMarker::SEQ);</span>
<span class="lineNum">     163 </span><span class="lineCov">      22455 :   m_simpleKeyAllowed = true;</span>
<span class="lineNum">     164 </span><span class="lineCov">      22455 :   m_canBeJSONFlow = false;</span>
<span class="lineNum">     165 </span>            : 
<span class="lineNum">     166 </span>            :   // eat
<span class="lineNum">     167 </span><span class="lineCov">      22455 :   Mark mark = INPUT.mark();</span>
<span class="lineNum">     168 </span><span class="lineCov">      22455 :   INPUT.eat(1);</span>
<span class="lineNum">     169 </span><span class="lineCov">      22455 :   m_tokens.push(Token(Token::BLOCK_ENTRY, mark));</span>
<span class="lineNum">     170 </span><span class="lineCov">      22455 : }</span>
<a name="171"><span class="lineNum">     171 </span>            : </a>
<span class="lineNum">     172 </span>            : // Key
<span class="lineNum">     173 </span><span class="lineCov">      15002 : void Scanner::ScanKey() {</span>
<span class="lineNum">     174 </span>            :   // handle keys diffently in the block context (and manage indents)
<span class="lineNum">     175 </span><span class="lineCov">      15002 :   if (InBlockContext()) {</span>
<span class="lineNum">     176 </span><span class="lineCov">      14787 :     if (!m_simpleKeyAllowed)</span>
<span class="lineNum">     177 </span><span class="lineCov">         20 :       throw ParserException(INPUT.mark(), ErrorMsg::MAP_KEY);</span>
<span class="lineNum">     178 </span>            : 
<span class="lineNum">     179 </span><span class="lineCov">      14767 :     PushIndentTo(INPUT.column(), IndentMarker::MAP);</span>
<span class="lineNum">     180 </span>            :   }
<span class="lineNum">     181 </span>            : 
<span class="lineNum">     182 </span>            :   // can only put a simple key here if we're in block context
<span class="lineNum">     183 </span><span class="lineCov">      14982 :   m_simpleKeyAllowed = InBlockContext();</span>
<span class="lineNum">     184 </span>            : 
<span class="lineNum">     185 </span>            :   // eat
<span class="lineNum">     186 </span><span class="lineCov">      14982 :   Mark mark = INPUT.mark();</span>
<span class="lineNum">     187 </span><span class="lineCov">      14982 :   INPUT.eat(1);</span>
<span class="lineNum">     188 </span><span class="lineCov">      14982 :   m_tokens.push(Token(Token::KEY, mark));</span>
<span class="lineNum">     189 </span><span class="lineCov">      14982 : }</span>
<a name="190"><span class="lineNum">     190 </span>            : </a>
<span class="lineNum">     191 </span>            : // Value
<span class="lineNum">     192 </span><span class="lineCov">      16753 : void Scanner::ScanValue() {</span>
<span class="lineNum">     193 </span>            :   // and check that simple key
<span class="lineNum">     194 </span><span class="lineCov">      16753 :   bool isSimpleKey = VerifySimpleKey();</span>
<span class="lineNum">     195 </span><span class="lineCov">      16753 :   m_canBeJSONFlow = false;</span>
<span class="lineNum">     196 </span>            : 
<span class="lineNum">     197 </span><span class="lineCov">      16753 :   if (isSimpleKey) {</span>
<span class="lineNum">     198 </span>            :     // can't follow a simple key with another simple key (dunno why, though - it
<span class="lineNum">     199 </span>            :     // seems fine)
<span class="lineNum">     200 </span><span class="lineCov">       8671 :     m_simpleKeyAllowed = false;</span>
<span class="lineNum">     201 </span>            :   } else {
<span class="lineNum">     202 </span>            :     // handle values diffently in the block context (and manage indents)
<span class="lineNum">     203 </span><span class="lineCov">       8082 :     if (InBlockContext()) {</span>
<span class="lineNum">     204 </span><span class="lineCov">       6588 :       if (!m_simpleKeyAllowed)</span>
<span class="lineNum">     205 </span><span class="lineCov">         46 :         throw ParserException(INPUT.mark(), ErrorMsg::MAP_VALUE);</span>
<span class="lineNum">     206 </span>            : 
<span class="lineNum">     207 </span><span class="lineCov">       6542 :       PushIndentTo(INPUT.column(), IndentMarker::MAP);</span>
<span class="lineNum">     208 </span>            :     }
<span class="lineNum">     209 </span>            : 
<span class="lineNum">     210 </span>            :     // can only put a simple key here if we're in block context
<span class="lineNum">     211 </span><span class="lineCov">       8036 :     m_simpleKeyAllowed = InBlockContext();</span>
<span class="lineNum">     212 </span>            :   }
<span class="lineNum">     213 </span>            : 
<span class="lineNum">     214 </span>            :   // eat
<span class="lineNum">     215 </span><span class="lineCov">      16707 :   Mark mark = INPUT.mark();</span>
<span class="lineNum">     216 </span><span class="lineCov">      16707 :   INPUT.eat(1);</span>
<span class="lineNum">     217 </span><span class="lineCov">      16707 :   m_tokens.push(Token(Token::VALUE, mark));</span>
<span class="lineNum">     218 </span><span class="lineCov">      16707 : }</span>
<a name="219"><span class="lineNum">     219 </span>            : </a>
<span class="lineNum">     220 </span>            : // AnchorOrAlias
<span class="lineNum">     221 </span><span class="lineCov">       5642 : void Scanner::ScanAnchorOrAlias() {</span>
<span class="lineNum">     222 </span>            :   bool alias;
<span class="lineNum">     223 </span><span class="lineCov">      11284 :   std::string name;</span>
<span class="lineNum">     224 </span>            : 
<span class="lineNum">     225 </span>            :   // insert a potential simple key
<span class="lineNum">     226 </span><span class="lineCov">       5642 :   InsertPotentialSimpleKey();</span>
<span class="lineNum">     227 </span><span class="lineCov">       5642 :   m_simpleKeyAllowed = false;</span>
<span class="lineNum">     228 </span><span class="lineCov">       5642 :   m_canBeJSONFlow = false;</span>
<span class="lineNum">     229 </span>            : 
<span class="lineNum">     230 </span>            :   // eat the indicator
<span class="lineNum">     231 </span><span class="lineCov">       5642 :   Mark mark = INPUT.mark();</span>
<span class="lineNum">     232 </span><span class="lineCov">       5642 :   char indicator = INPUT.get();</span>
<span class="lineNum">     233 </span><span class="lineCov">       5642 :   alias = (indicator == Keys::Alias);</span>
<span class="lineNum">     234 </span>            : 
<span class="lineNum">     235 </span>            :   // now eat the content
<span class="lineNum">     236 </span><span class="lineCov">      85544 :   while (INPUT &amp;&amp; Exp::Anchor().Matches(INPUT))</span>
<span class="lineNum">     237 </span><span class="lineCov">      39951 :     name += INPUT.get();</span>
<span class="lineNum">     238 </span>            : 
<span class="lineNum">     239 </span>            :   // we need to have read SOMETHING!
<span class="lineNum">     240 </span><span class="lineCov">       5642 :   if (name.empty())</span>
<span class="lineNum">     241 </span><span class="lineCov">         18 :     throw ParserException(INPUT.mark(), alias ? ErrorMsg::ALIAS_NOT_FOUND</span>
<span class="lineNum">     242 </span><span class="lineCov">         27 :                                               : ErrorMsg::ANCHOR_NOT_FOUND);</span>
<span class="lineNum">     243 </span>            : 
<span class="lineNum">     244 </span>            :   // and needs to end correctly
<span class="lineNum">     245 </span><span class="lineCov">       5633 :   if (INPUT &amp;&amp; !Exp::AnchorEnd().Matches(INPUT))</span>
<span class="lineNum">     246 </span><span class="lineCov">          8 :     throw ParserException(INPUT.mark(), alias ? ErrorMsg::CHAR_IN_ALIAS</span>
<span class="lineNum">     247 </span><span class="lineCov">         12 :                                               : ErrorMsg::CHAR_IN_ANCHOR);</span>
<span class="lineNum">     248 </span>            : 
<span class="lineNum">     249 </span>            :   // and we're done
<span class="lineNum">     250 </span><span class="lineCov">      11258 :   Token token(alias ? Token::ALIAS : Token::ANCHOR, mark);</span>
<span class="lineNum">     251 </span><span class="lineCov">       5629 :   token.value = name;</span>
<span class="lineNum">     252 </span><span class="lineCov">       5629 :   m_tokens.push(token);</span>
<span class="lineNum">     253 </span><span class="lineCov">       5629 : }</span>
<a name="254"><span class="lineNum">     254 </span>            : </a>
<span class="lineNum">     255 </span>            : // Tag
<span class="lineNum">     256 </span><span class="lineCov">       8059 : void Scanner::ScanTag() {</span>
<span class="lineNum">     257 </span>            :   // insert a potential simple key
<span class="lineNum">     258 </span><span class="lineCov">       8059 :   InsertPotentialSimpleKey();</span>
<span class="lineNum">     259 </span><span class="lineCov">       8059 :   m_simpleKeyAllowed = false;</span>
<span class="lineNum">     260 </span><span class="lineCov">       8059 :   m_canBeJSONFlow = false;</span>
<span class="lineNum">     261 </span>            : 
<span class="lineNum">     262 </span><span class="lineCov">      16118 :   Token token(Token::TAG, INPUT.mark());</span>
<span class="lineNum">     263 </span>            : 
<span class="lineNum">     264 </span>            :   // eat the indicator
<span class="lineNum">     265 </span><span class="lineCov">       8059 :   INPUT.get();</span>
<span class="lineNum">     266 </span>            : 
<span class="lineNum">     267 </span><span class="lineCov">       8059 :   if (INPUT &amp;&amp; INPUT.peek() == Keys::VerbatimTagStart) {</span>
<span class="lineNum">     268 </span><span class="lineCov">       1318 :     std::string tag = ScanVerbatimTag(INPUT);</span>
<span class="lineNum">     269 </span>            : 
<span class="lineNum">     270 </span><span class="lineCov">        653 :     token.value = tag;</span>
<span class="lineNum">     271 </span><span class="lineCov">        653 :     token.data = Tag::VERBATIM;</span>
<span class="lineNum">     272 </span>            :   } else {
<span class="lineNum">     273 </span>            :     bool canBeHandle;
<span class="lineNum">     274 </span><span class="lineCov">       7394 :     token.value = ScanTagHandle(INPUT, canBeHandle);</span>
<span class="lineNum">     275 </span><span class="lineCov">       7390 :     if (!canBeHandle &amp;&amp; token.value.empty())</span>
<span class="lineNum">     276 </span><span class="lineCov">       1962 :       token.data = Tag::NON_SPECIFIC;</span>
<span class="lineNum">     277 </span><span class="lineCov">       5428 :     else if (token.value.empty())</span>
<span class="lineNum">     278 </span><span class="lineCov">       3141 :       token.data = Tag::SECONDARY_HANDLE;</span>
<span class="lineNum">     279 </span>            :     else
<span class="lineNum">     280 </span><span class="lineCov">       2287 :       token.data = Tag::PRIMARY_HANDLE;</span>
<span class="lineNum">     281 </span>            : 
<span class="lineNum">     282 </span>            :     // is there a suffix?
<span class="lineNum">     283 </span><span class="lineCov">       7390 :     if (canBeHandle &amp;&amp; INPUT.peek() == Keys::Tag) {</span>
<span class="lineNum">     284 </span>            :       // eat the indicator
<span class="lineNum">     285 </span><span class="lineCov">       3526 :       INPUT.get();</span>
<span class="lineNum">     286 </span><span class="lineCov">       3526 :       token.params.push_back(ScanTagSuffix(INPUT));</span>
<span class="lineNum">     287 </span><span class="lineCov">       3511 :       token.data = Tag::NAMED_HANDLE;</span>
<span class="lineNum">     288 </span>            :     }
<span class="lineNum">     289 </span>            :   }
<span class="lineNum">     290 </span>            : 
<span class="lineNum">     291 </span><span class="lineCov">       8028 :   m_tokens.push(token);</span>
<span class="lineNum">     292 </span><span class="lineCov">       8028 : }</span>
<a name="293"><span class="lineNum">     293 </span>            : </a>
<span class="lineNum">     294 </span>            : // PlainScalar
<span class="lineNum">     295 </span><span class="lineCov">      30054 : void Scanner::ScanPlainScalar() {</span>
<span class="lineNum">     296 </span><span class="lineCov">      60108 :   std::string scalar;</span>
<span class="lineNum">     297 </span>            : 
<span class="lineNum">     298 </span>            :   // set up the scanning parameters
<span class="lineNum">     299 </span><span class="lineCov">      30054 :   ScanScalarParams params;</span>
<span class="lineNum">     300 </span>            :   params.end =
<span class="lineNum">     301 </span><span class="lineCov">      30054 :       (InFlowContext() ? &amp;Exp::ScanScalarEndInFlow() : &amp;Exp::ScanScalarEnd());</span>
<span class="lineNum">     302 </span><span class="lineCov">      30054 :   params.eatEnd = false;</span>
<span class="lineNum">     303 </span><span class="lineCov">      30054 :   params.indent = (InFlowContext() ? 0 : GetTopIndent() + 1);</span>
<span class="lineNum">     304 </span><span class="lineCov">      30054 :   params.fold = FOLD_FLOW;</span>
<span class="lineNum">     305 </span><span class="lineCov">      30054 :   params.eatLeadingWhitespace = true;</span>
<span class="lineNum">     306 </span><span class="lineCov">      30054 :   params.trimTrailingSpaces = true;</span>
<span class="lineNum">     307 </span><span class="lineCov">      30054 :   params.chomp = STRIP;</span>
<span class="lineNum">     308 </span><span class="lineCov">      30054 :   params.onDocIndicator = BREAK;</span>
<span class="lineNum">     309 </span><span class="lineCov">      30054 :   params.onTabInIndentation = THROW;</span>
<span class="lineNum">     310 </span>            : 
<span class="lineNum">     311 </span>            :   // insert a potential simple key
<span class="lineNum">     312 </span><span class="lineCov">      30054 :   InsertPotentialSimpleKey();</span>
<span class="lineNum">     313 </span>            : 
<span class="lineNum">     314 </span><span class="lineCov">      30054 :   Mark mark = INPUT.mark();</span>
<span class="lineNum">     315 </span><span class="lineCov">      30054 :   scalar = ScanScalar(INPUT, params);</span>
<span class="lineNum">     316 </span>            : 
<span class="lineNum">     317 </span>            :   // can have a simple key only if we ended the scalar by starting a new line
<span class="lineNum">     318 </span><span class="lineCov">      29746 :   m_simpleKeyAllowed = params.leadingSpaces;</span>
<span class="lineNum">     319 </span><span class="lineCov">      29746 :   m_canBeJSONFlow = false;</span>
<span class="lineNum">     320 </span>            : 
<span class="lineNum">     321 </span>            :   // finally, check and see if we ended on an illegal character
<span class="lineNum">     322 </span>            :   // if(Exp::IllegalCharInScalar.Matches(INPUT))
<span class="lineNum">     323 </span>            :   //    throw ParserException(INPUT.mark(), ErrorMsg::CHAR_IN_SCALAR);
<span class="lineNum">     324 </span>            : 
<span class="lineNum">     325 </span><span class="lineCov">      59492 :   Token token(Token::PLAIN_SCALAR, mark);</span>
<span class="lineNum">     326 </span><span class="lineCov">      29746 :   token.value = scalar;</span>
<span class="lineNum">     327 </span><span class="lineCov">      29746 :   m_tokens.push(token);</span>
<span class="lineNum">     328 </span><span class="lineCov">      29746 : }</span>
<a name="329"><span class="lineNum">     329 </span>            : </a>
<span class="lineNum">     330 </span>            : // QuotedScalar
<span class="lineNum">     331 </span><span class="lineCov">       2507 : void Scanner::ScanQuotedScalar() {</span>
<span class="lineNum">     332 </span><span class="lineCov">       5014 :   std::string scalar;</span>
<span class="lineNum">     333 </span>            : 
<span class="lineNum">     334 </span>            :   // peek at single or double quote (don't eat because we need to preserve (for
<span class="lineNum">     335 </span>            :   // the time being) the input position)
<span class="lineNum">     336 </span><span class="lineCov">       2507 :   char quote = INPUT.peek();</span>
<span class="lineNum">     337 </span><span class="lineCov">       2507 :   bool single = (quote == '\'');</span>
<span class="lineNum">     338 </span>            : 
<span class="lineNum">     339 </span>            :   // setup the scanning parameters
<span class="lineNum">     340 </span><span class="lineCov">       2507 :   ScanScalarParams params;</span>
<span class="lineNum">     341 </span><span class="lineCov">       5014 :   RegEx end = (single ? RegEx(quote) &amp;&amp; !Exp::EscSingleQuote() : RegEx(quote));</span>
<span class="lineNum">     342 </span><span class="lineCov">       2507 :   params.end = &amp;end;</span>
<span class="lineNum">     343 </span><span class="lineCov">       2507 :   params.eatEnd = true;</span>
<span class="lineNum">     344 </span><span class="lineCov">       2507 :   params.escape = (single ? '\'' : '\\');</span>
<span class="lineNum">     345 </span><span class="lineCov">       2507 :   params.indent = 0;</span>
<span class="lineNum">     346 </span><span class="lineCov">       2507 :   params.fold = FOLD_FLOW;</span>
<span class="lineNum">     347 </span><span class="lineCov">       2507 :   params.eatLeadingWhitespace = true;</span>
<span class="lineNum">     348 </span><span class="lineCov">       2507 :   params.trimTrailingSpaces = false;</span>
<span class="lineNum">     349 </span><span class="lineCov">       2507 :   params.chomp = CLIP;</span>
<span class="lineNum">     350 </span><span class="lineCov">       2507 :   params.onDocIndicator = THROW;</span>
<span class="lineNum">     351 </span>            : 
<span class="lineNum">     352 </span>            :   // insert a potential simple key
<span class="lineNum">     353 </span><span class="lineCov">       2507 :   InsertPotentialSimpleKey();</span>
<span class="lineNum">     354 </span>            : 
<span class="lineNum">     355 </span><span class="lineCov">       2507 :   Mark mark = INPUT.mark();</span>
<span class="lineNum">     356 </span>            : 
<span class="lineNum">     357 </span>            :   // now eat that opening quote
<span class="lineNum">     358 </span><span class="lineCov">       2507 :   INPUT.get();</span>
<span class="lineNum">     359 </span>            : 
<span class="lineNum">     360 </span>            :   // and scan
<span class="lineNum">     361 </span><span class="lineCov">       2507 :   scalar = ScanScalar(INPUT, params);</span>
<span class="lineNum">     362 </span><span class="lineCov">       2471 :   m_simpleKeyAllowed = false;</span>
<span class="lineNum">     363 </span><span class="lineCov">       2471 :   m_canBeJSONFlow = true;</span>
<span class="lineNum">     364 </span>            : 
<span class="lineNum">     365 </span><span class="lineCov">       4942 :   Token token(Token::NON_PLAIN_SCALAR, mark);</span>
<span class="lineNum">     366 </span><span class="lineCov">       2471 :   token.value = scalar;</span>
<span class="lineNum">     367 </span><span class="lineCov">       2471 :   m_tokens.push(token);</span>
<span class="lineNum">     368 </span><span class="lineCov">       2471 : }</span>
<span class="lineNum">     369 </span>            : 
<span class="lineNum">     370 </span>            : // BlockScalarToken
<span class="lineNum">     371 </span>            : // . These need a little extra processing beforehand.
<span class="lineNum">     372 </span>            : // . We need to scan the line where the indicator is (this doesn't count as part
<a name="373"><span class="lineNum">     373 </span>            : // of the scalar),</a>
<span class="lineNum">     374 </span>            : //   and then we need to figure out what level of indentation we'll be using.
<span class="lineNum">     375 </span><span class="lineCov">        503 : void Scanner::ScanBlockScalar() {</span>
<span class="lineNum">     376 </span><span class="lineCov">       1006 :   std::string scalar;</span>
<span class="lineNum">     377 </span>            : 
<span class="lineNum">     378 </span><span class="lineCov">        503 :   ScanScalarParams params;</span>
<span class="lineNum">     379 </span><span class="lineCov">        503 :   params.indent = 1;</span>
<span class="lineNum">     380 </span><span class="lineCov">        503 :   params.detectIndent = true;</span>
<span class="lineNum">     381 </span>            : 
<span class="lineNum">     382 </span>            :   // eat block indicator ('|' or '&gt;')
<span class="lineNum">     383 </span><span class="lineCov">        503 :   Mark mark = INPUT.mark();</span>
<span class="lineNum">     384 </span><span class="lineCov">        503 :   char indicator = INPUT.get();</span>
<span class="lineNum">     385 </span><span class="lineCov">        503 :   params.fold = (indicator == Keys::FoldedScalar ? FOLD_BLOCK : DONT_FOLD);</span>
<span class="lineNum">     386 </span>            : 
<span class="lineNum">     387 </span>            :   // eat chomping/indentation indicators
<span class="lineNum">     388 </span><span class="lineCov">        503 :   params.chomp = CLIP;</span>
<span class="lineNum">     389 </span><span class="lineCov">        503 :   int n = Exp::Chomp().Match(INPUT);</span>
<span class="lineNum">     390 </span><span class="lineCov">        547 :   for (int i = 0; i &lt; n; i++) {</span>
<span class="lineNum">     391 </span><span class="lineCov">         56 :     char ch = INPUT.get();</span>
<span class="lineNum">     392 </span><span class="lineCov">         56 :     if (ch == '+')</span>
<span class="lineNum">     393 </span><span class="lineCov">          8 :       params.chomp = KEEP;</span>
<span class="lineNum">     394 </span><span class="lineCov">         48 :     else if (ch == '-')</span>
<span class="lineNum">     395 </span><span class="lineCov">          8 :       params.chomp = STRIP;</span>
<span class="lineNum">     396 </span><span class="lineCov">         40 :     else if (Exp::Digit().Matches(ch)) {</span>
<span class="lineNum">     397 </span><span class="lineCov">         40 :       if (ch == '0')</span>
<span class="lineNum">     398 </span><span class="lineCov">         12 :         throw ParserException(INPUT.mark(), ErrorMsg::ZERO_INDENT_IN_BLOCK);</span>
<span class="lineNum">     399 </span>            : 
<span class="lineNum">     400 </span><span class="lineCov">         28 :       params.indent = ch - '0';</span>
<span class="lineNum">     401 </span><span class="lineCov">         28 :       params.detectIndent = false;</span>
<span class="lineNum">     402 </span>            :     }
<span class="lineNum">     403 </span>            :   }
<span class="lineNum">     404 </span>            : 
<span class="lineNum">     405 </span>            :   // now eat whitespace
<span class="lineNum">     406 </span><span class="lineCov">       1279 :   while (Exp::Blank().Matches(INPUT))</span>
<span class="lineNum">     407 </span><span class="lineCov">        394 :     INPUT.eat(1);</span>
<span class="lineNum">     408 </span>            : 
<span class="lineNum">     409 </span>            :   // and comments to the end of the line
<span class="lineNum">     410 </span><span class="lineCov">        491 :   if (Exp::Comment().Matches(INPUT))</span>
<span class="lineNum">     411 </span><span class="lineCov">       4870 :     while (INPUT &amp;&amp; !Exp::Break().Matches(INPUT))</span>
<span class="lineNum">     412 </span><span class="lineCov">       2394 :       INPUT.eat(1);</span>
<span class="lineNum">     413 </span>            : 
<span class="lineNum">     414 </span>            :   // if it's not a line break, then we ran into a bad character inline
<span class="lineNum">     415 </span><span class="lineCov">        491 :   if (INPUT &amp;&amp; !Exp::Break().Matches(INPUT))</span>
<span class="lineNum">     416 </span><span class="lineCov">         14 :     throw ParserException(INPUT.mark(), ErrorMsg::CHAR_IN_BLOCK);</span>
<span class="lineNum">     417 </span>            : 
<span class="lineNum">     418 </span>            :   // set the initial indentation
<span class="lineNum">     419 </span><span class="lineCov">        477 :   if (GetTopIndent() &gt;= 0)</span>
<span class="lineNum">     420 </span><span class="lineCov">        332 :     params.indent += GetTopIndent();</span>
<span class="lineNum">     421 </span>            : 
<span class="lineNum">     422 </span><span class="lineCov">        477 :   params.eatLeadingWhitespace = false;</span>
<span class="lineNum">     423 </span><span class="lineCov">        477 :   params.trimTrailingSpaces = false;</span>
<span class="lineNum">     424 </span><span class="lineCov">        477 :   params.onTabInIndentation = THROW;</span>
<span class="lineNum">     425 </span>            : 
<span class="lineNum">     426 </span><span class="lineCov">        477 :   scalar = ScanScalar(INPUT, params);</span>
<span class="lineNum">     427 </span>            : 
<span class="lineNum">     428 </span>            :   // simple keys always ok after block scalars (since we're gonna start a new
<span class="lineNum">     429 </span>            :   // line anyways)
<span class="lineNum">     430 </span><span class="lineCov">        469 :   m_simpleKeyAllowed = true;</span>
<span class="lineNum">     431 </span><span class="lineCov">        469 :   m_canBeJSONFlow = false;</span>
<span class="lineNum">     432 </span>            : 
<span class="lineNum">     433 </span><span class="lineCov">        938 :   Token token(Token::NON_PLAIN_SCALAR, mark);</span>
<span class="lineNum">     434 </span><span class="lineCov">        469 :   token.value = scalar;</span>
<a name="435"><span class="lineNum">     435 </span><span class="lineCov">        469 :   m_tokens.push(token);</span></a>
<span class="lineNum">     436 </span><span class="lineCov">        469 : }</span>
<span class="lineNum">     437 </span><span class="lineCov">       6108 : }</span>
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.11</a></td></tr>
  </table>
  <br>

</body>
</html>
